Working with Python input() Function
The Python input() function is used to take input from standard input devices. With the help of this function, you can ask user to provide values to a program at run time.
When a Python program is running and a input function is called. The program execution will wait until the user send a input and press return key.
Syntax
input(prompt)
Example:
Below sample Python program will print a message on screen. Then input() will ask your to enter your name.
1 2 3 | print("Enter your name: ") x = input() print('Welcome ' + x) |
Another example of Python input() function. Here the prompt message is passed as a parameter.
1 2 | x = input("Enter your name: ") print('Welcome ' + x) |